import type { ProColumns } from '@ant-design/pro-table';
import { IPFSListItem, columnsDataType } from './data.d';
import { getDictType } from '@/services/services';

export const columnsData: ProColumns<columnsDataType>[] = [
  // table里面的内容
  {
    title: '序号',
    dataIndex: 'order',
    valueType: 'indexBorder',
    hideInSearch: true,
    width: 50,
    fixed: 'left',
  },
  {
    title: '主题名称',
    width: 100,
    fixed: 'left',
    dataIndex: 'themeName',
    hideInSearch: true,
  },
  {
    title: '主题类型',
    dataIndex: 'type',
    width: 100,
    hideInSearch: true,
    valueType: 'select',
    request: (a) =>
      getDictType({
        dictType: 'theme-nft-type',
        pageSize: 10,
        current: 1,
      }).then((res: any) => {
        console.log(res);

        let data: any = [];
        res.data.map((item: any, index: number) => {
          data[index] = {
            value: item.itemValue,
            label: item.label,
          };
        });
        return data;
      }),
  },
  {
    title: '主题性别',
    dataIndex: 'sex',
    width: 100,
    hideInSearch: true,
    valueType: 'select',
    valueEnum: {
      0: {
        text: '男',
      },
      1: {
        text: '女',
      },
      2: {
        text: '无性别',
      },
    },
  },
  {
    title: '总供应量',
    width: 100,
    dataIndex: 'totalSupply',
    hideInSearch: true,
  },
  {
    title: '铸造时间',
    dataIndex: 'createTime',
    hideInSearch: true,
    width: 160,
  },
  {
    title: '流通状态',
    dataIndex: 'status',
    hideInSearch: true,
    valueType: 'select',
    width: 100,
    valueEnum: {
      0: {
        text: '已发行',
      },
      1: {
        text: '未发行',
      },
    },
  },
  {
    title: '操作',
    dataIndex: 'action',
    hideInSearch: true,
    width: 100,
    fixed: 'right',
  },
];

export const IPFSColumns: ProColumns<IPFSListItem>[] = [
  {
    title: '序号',
    dataIndex: 'order',
    valueType: 'indexBorder',
    hideInSearch: true,
    width: 50,
    fixed: 'left',
  },
  {
    title: '主题名称',
    width: 160,
    dataIndex: 'metadataName',
    hideInSearch: true,
    fixed: 'left',
  },
  {
    title: '性别',
    width: 80,
    dataIndex: 'sex',
    valueType: 'select',
    hideInSearch: true,
    valueEnum: {
      0: {
        text: '男',
      },
      1: {
        text: '女',
      },
      2: {
        text: '无',
      },
    },
  },
  {
    title: '是否为碎片',
    width: 120,
    dataIndex: 'fragmentsFlag',
    valueType: 'select',
    hideInSearch: true,
    valueEnum: {
      0: {
        text: '否',
      },
      1: {
        text: '是',
      },
    },
  },
  {
    title: '碎片编号',
    width: 120,
    dataIndex: 'fragmentsSerialNo',
    hideInSearch: true,
  },
  {
    title: '元数据图片',
    dataIndex: 'metadataImage',
    hideInSearch: true,
    width: 100,
    valueType: 'image',
  },
  {
    title: '元数据',
    dataIndex: 'metadataUrl',
    hideInSearch: true,
  },
];
